const colorPallete = [205,44,36]
const colorName = {
    1: '红色',
    2: '绿色',
    3: '蓝色',
    4: '黄色',
    5: '青色',
    6: '紫色',
    7: '白色',
    8: '黑色',
    0: '其他'
}
const insertData = {
    color:`rgb(${colorPallete[0]}, ${colorPallete[1]}, ${colorPallete[2]})`,
    colorType: '0'
}
// 定义容差值
const tolerance = 30;

if (colorPallete[0] > 200 && Math.abs(colorPallete[1] - 0) < tolerance && Math.abs(colorPallete[2] - 0) < tolerance) {
    insertData.colorType = '1'; // 红色
} else if (Math.abs(colorPallete[0] - 0) < tolerance && colorPallete[1] > 200 && Math.abs(colorPallete[2] - 0) < tolerance) {
    insertData.colorType = '2'; // 绿色
} else if (Math.abs(colorPallete[0] - 0) < tolerance && Math.abs(colorPallete[1] - 0) < tolerance && colorPallete[2] > 200) {
    insertData.colorType = '3'; // 蓝色
} else if (colorPallete[0] > 200 && colorPallete[1] > 200 && Math.abs(colorPallete[2] - 0) < tolerance) {
    insertData.colorType = '4'; // 黄色
} else if (Math.abs(colorPallete[0] - 0) < tolerance && colorPallete[1] > 200 && colorPallete[2] > 200) {
    insertData.colorType = '5'; // 青色
} else if (colorPallete[0] > 200 && Math.abs(colorPallete[1] - 0) < tolerance && colorPallete[2] > 200) {
    insertData.colorType = '6'; // 紫色
} else if (colorPallete[0] > 200 && colorPallete[1] > 200 && colorPallete[2] > 200) {
    insertData.colorType = '7'; // 白色
} else if (Math.abs(colorPallete[0] - 0) < tolerance && Math.abs(colorPallete[1] - 0) < tolerance && Math.abs(colorPallete[2] - 0) < tolerance) {
    insertData.colorType = '8'; // 黑色
} else {
    insertData.colorType = '0'; // 其他
}
console.log(insertData)
